package coreModelTests;

import static org.junit.Assert.*;

import hitExceptions.InvalidOperationException;

import java.util.Collection;
import java.util.Collections;

import org.junit.BeforeClass;
import org.junit.Test;

import coreModel.*;

public class SerialilzerTest {
	static HIT theHit;
	@BeforeClass
	public static void setUpBeforeClass() throws Exception
	{
		theHit= HIT.getInstance();
		theHit.addStorageUnit(new StorageUnit("the Unit"));

	}

	@Test
	public void testSaveObjectsHITString() throws InvalidOperationException
	{
		try
		{
			Collection<StorageUnit> beforeSave = theHit.getAllStorageUnits();
			theHit.save("testingHit");
			theHit.load("testingHit");

			assertEquals(beforeSave,theHit.getAllStorageUnits());

			StorageUnit su= new StorageUnit("other Unit");
			theHit.addStorageUnit(su);

			//beforeSave.add(new StorageUnit("should not be here"));

			assertNotSame(beforeSave,theHit.getAllStorageUnits());
			theHit.save("testingHit");
			theHit.load("testingHit");
			assertNotSame(beforeSave,theHit.getAllStorageUnits());
			beforeSave.add(su);
			assertEquals(beforeSave,theHit.getAllStorageUnits());
		}
		catch(Exception e)
		{
			e.printStackTrace();
			fail();
		}
	}



}
